/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.persistence.manager;

import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.SimpleTransactionStatus;

/**
 * fake implementation of <code>PlatformTransactionManager</code>. The memory
 * implementation of the persistence API does not support transactions.
 */
public class SimpleTransactionManager
    implements PlatformTransactionManager
{

  /**
   * Commit the given transaction, with regard to its status. If the transaction
   * has been marked rollback-only programmatically, perform a rollback.
   * 
   * @param status
   *          object returned by the getTransaction method
   * @see org.springframework.transaction.PlatformTransactionManager#commit(org.springframework.transaction.TransactionStatus)
   */
  public void commit(final TransactionStatus status)
  {
    // Do Nothing. The Memory Persistence Implementation does not support
    // transaction.
  }



  /**
   * Return a currently active transaction or create a new one, according to the
   * specified propagation behavior.
   * 
   * @param definition
   *          TransactionDefinition instance (can be <code>null</code> for
   *          defaults), describing propagation behavior, isolation level,
   *          timeout etc.
   * @return transaction status object representing the new or current
   *         transaction
   * @see org.springframework.transaction.PlatformTransactionManager#getTransaction(org.springframework.transaction.TransactionDefinition)
   */
  public TransactionStatus getTransaction(final TransactionDefinition definition)
  {
    return new SimpleTransactionStatus();
  }



  /**
   * Perform a rollback of the given transaction.
   * 
   * @param status
   *          object returned by the getTransaction method
   * @see org.springframework.transaction.PlatformTransactionManager#rollback(org.springframework.transaction.TransactionStatus)
   */
  public void rollback(final TransactionStatus status)
  {
    // Do Nothing. The Memory Persistence Implementation does not support
    // transaction.
  }

}
